package com.itheima.tanhua.api;

import com.itheima.tanhua.api.mongo.MessagesServiceApi;
import com.itheima.tanhuan.pojo.db.Friend;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;


import java.util.List;

@DubboService
public class MessagesServiceApiImpl implements MessagesServiceApi {
    @Autowired
    MongoTemplate mongoTemplate;
    @Override
    public List<Friend> findFriendsById(Long uid, Integer page, Integer pageSize, String keyWord) {
        //分页查询
        Query query=Query.query(Criteria.where("userId").is(uid)).skip((page-1)*pageSize).limit(pageSize);
        List<Friend> friendList = mongoTemplate.find(query, Friend.class);
        return friendList;
    }
}
